home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / bbintro.lha / B_Block_Scroll.s next >
Encoding:
Text File  |  1992-12-31  |  4.7 KB  |  184 lines

  1. ************************************************************
  2. * How to create this program:
  3. *
  4. * For normal executable:
  5. * 1. Make sure BOOT_BLOCK is EQU'ed to 0.
  6. * 2. From the AsmOne prompt type a<RETURN>.
  7. * 3. Then type wo<RETURN>
  8. *
  9. * For a boot block:
  10. * 1. Make sure BOOT_BLOCK is EQU'ed to 1.
  11. * 2. From the AsmOne prompt type a<RETURN>.
  12. * 3. Put the disk you want the boot block on in df0:.
  13. * 4. Type ws<RETURN>.
  14. * 5. Do the following sequence, as prompted:
  15. *    RAM_PTR> Start
  16. *    DISK_PTR> 0
  17. *    LENGTH> 2
  18. * 6. Now, type cc<RETURN>
  19. * 7. Reboot to see the boot block!
  20. ************************************************************
  21.  
  22. BOOT_BLOCK    EQU    1        ; 0 = normal exe, 1 = boot block
  23. HEIGHT        EQU    9        ; height of font, in rasters
  24.  
  25. ************************************************************
  26.  
  27. WaitVblank    MACRO
  28. .\@        move.l    2(a5),d0
  29.         andi.l    #$3ff00,d0
  30.         cmpi.l    #$0f000,d0
  31.         bne.b    .\@
  32. .\@1        move.l    2(a5),d0
  33.         andi.l    #$3ff00,d0
  34.         cmpi.l    #$0f000,d0
  35.         beq.b    .\@1
  36.         ENDM
  37.  
  38. ************************************************************
  39.  
  40.  IFNE    BOOT_BLOCK
  41. Start:
  42.         dc.b    "DOS",0
  43.         dc.l    0            ; BB checksum goes here
  44.         dc.l    $370            ; root block
  45.  ELSE
  46.         section    thpt,code_c
  47.  ENDIF 
  48.  
  49.         movem.l    d1-d7/a1-a6,-(sp)    ; save all registers
  50.         lea    scroll_pad(pc),a1    ; where we scroll
  51.         moveq    #125,d0            ; counter
  52. .1:        clr.l    (a1)+            ; clear the scroll pad
  53.         dbf    d0,.1            ;   since we just stomp on
  54.                         ;   memory like a bunch of
  55.                         ;   turds.
  56.  
  57.         lea    mapptrs+2(pc),a0    ; our clist bmap ptrs
  58.         lea    scroll_pad(pc),a1    ; our screen
  59.         move.l    a1,d0
  60.         move.w    d0,4(a0)        ; low word
  61.         swap    d0
  62.         move.w    d0,(a0)            ; high word
  63.  
  64.         lea    $dff002,a5        ; Custom chip base + 2
  65.         move.w    #$81c0,$96-2(a5)    ; enable blitter, copper,
  66.                         ;   and bitplane DMS
  67.         tst.b    (a5)            ; wait for the blitter
  68. .11:        btst.b    #6,(a5)
  69.         bne.b    .11
  70.  
  71.  IFEQ BOOT_BLOCK
  72.         move.w    $1c-2(a5),d0        ; save old int bits
  73.         or.w    d0,INTSave
  74.  ENDIF
  75.         lea    Copper(pc),a0        ; our copper
  76.         move.l    a0,$80-2(a5)        ; install it
  77.  
  78.         lea    ScrollTextPtr(pc),a4
  79.         move.l    a2,(a4)
  80.         lea    scrolls(pc),a6
  81.  
  82.         moveq    #0,d2
  83.         move.l    #$19f00002,d3        ; bltcon0 & bltcon1
  84.         moveq    #-1,d4            ; bltfwm & bltlwm
  85.         moveq    #$3c,d6
  86.         moveq    #$32,d7
  87.  
  88.         movem.l    d3/d4,$40-2(a5)        ; preload these into their
  89.         move.l    d2,$64-2(a5)        ;   blit regs and they never
  90.                         ;   change! ;^)
  91.         lea    scroll_pad+(HEIGHT*48)(pc),a2
  92.  
  93. MouseWait:    WaitVblank            ; wait for the vblank
  94.  
  95.         tst.w    (a6)            ; scroll count = 0?
  96.         bgt.w    move_it            ; nope.
  97.         move.w    #8,(a6)            ; reset to 8
  98.  
  99.         move.l    (a4),a3            ; pointer to scroll text
  100.         tst.b    (a3)            ; end of text?
  101.         bne.s    nextchar        ; nope.
  102.         lea    ScrollText(pc),a3    ; reload
  103. nextchar:    moveq    #0,d0            ; clear
  104.         move.b    (a3)+,d0        ; fetch the character
  105.         move.l    a3,(a4)            ; save new pointer
  106.  
  107.         lea    scroll_pad+46(pc),a1
  108.         lea    Font-32(pc,d0.w),a0    ; this finds our char. in the
  109.                         ;   font, too.
  110.         moveq    #HEIGHT,d0        ; how many lines in font
  111. .1:        move.b    (a0),(a1)        ; copy byte
  112.         adda.w    d6,a0            ; next line in font
  113.         adda.w    d7,a1            ; next line on screen
  114.         dbf    d0,.1            ; loop!
  115.  
  116. move_it:    move.l    a2,a0            ; copy for the cool movem!
  117.         movem.l    a0/a2,$50-2(a5)        ; src/dest
  118.          move.w    #(64*HEIGHT)+24,$58-2(a5) ; bltsize
  119.  
  120.         subq.w    #1,(a6)            ; dec scroll count
  121.  
  122.         btst.b    #6,$bfe001        ; wait for left mouse button
  123.         bne.w    MouseWait        ; loop!
  124.  
  125. *************
  126.  IFEQ BOOT_BLOCK
  127.         move.w    INTSave(pc),$1c-2(a5)    ; restor old int bits.
  128.  ENDIF
  129.  
  130.         movea.l    4.w,a6            ; exec base
  131.         lea    GfxName(pc),a1        ; "graphics.library"
  132.         jsr    -$198(a6)        ; OldOpenLibrary()
  133.         move.l    d0,a1            ; ptr to gfx
  134.         move.l    $26(a1),$80-2(a5)    ; reinstall old sys clist
  135.         jsr    -$19e(a6)        ; CloseLibrary()
  136.  
  137.         lea    DosName(pc),a1        ; pointer to lib. name
  138.         jsr    -$60(a6)        ; FindResident()
  139.         tst.l    d0            ; did we find it?
  140.         beq.b    .no_dos            ; nope.
  141.         move.l    d0,a0            ; put in a0
  142.         move.l    $16(a0),a0        ; this is what we really need
  143.         moveq    #0,d0            ; clear
  144. .end:        movem.l    (a7)+,d1-d7/a1-a6    ; restore other regs.
  145.         rts                ; Done
  146.  
  147. .no_dos:    moveq    #-1,d0            ; error code
  148.         bra.b    .end            ; out
  149.  
  150. ***********************************************************    
  151.  
  152. scrolls:    dc.w    8
  153.  
  154. Font:        incbin    'ackfont.raw'
  155.  
  156. DosName:    dc.b    'dos.library',0
  157. GfxName:    dc.b    'graphics.library',0
  158.  
  159. ScrollText:    DC.B    " YEAH! A BOOTBLOCK SCROLLER! TOO COOL, EH? "
  160.         DC.B    "CONTACT ME AT: EPSILON   P.O.B. 1914    "
  161.         DC.B    "BEAVERTON, OR  97075-1914    U.S.A.   ",0
  162.         even
  163.     
  164. Copper:    dc.w    $0100,$0200,$0102,$0000,$0104,$0000,$0108,$0004
  165.     dc.w    $0180,$0000,$0182,$0fff,$008e,$2c6a,$0090,$f4fc,$0092,$0028
  166.     dc.w    $0094,$00d8
  167.     dc.w    $8a0f,$fffe,$0180,$0f00,$8b0f,$fffe,$0180,$0800
  168.     dc.w    $8c0f,$fffe,$0100,$1200
  169. mapptrs:dc.w    $00e0,$0000,$00e2,$0000
  170.     dc.w    $950f,$fffe,$0180,$0f00,$0100,$0000,$960f,$fffe,$0180,$0000
  171.     dc.l    -2,-2
  172.  
  173. blat:
  174.  IFEQ    BOOT_BLOCK
  175. ScrollTextPtr:    dc.l    ScrollText
  176. INTSave:    dc.w    $c000
  177.         ds.b    12*42
  178. scroll_pad:    ds.b    12*42
  179.         ds.b    12*42
  180.  ELSE
  181. ScrollTextPtr    EQU    blat
  182. scroll_pad    EQU    blat+(12*42)
  183.  ENDIF    
  184.